<template>
  <t-card class="eco-news-card">
    <t-space direction="vertical" style="width: 100%">
      <div class="eco-header">
        <h2 class="eco-title">
          <span class="eco-icon">🌱</span>
          绿色环保新闻管理
        </h2>
        <p class="eco-subtitle">守护地球，传播绿色理念</p>
      </div>
      <t-form v-show="showSearch" ref="queryRef" :data="queryParams" layout="inline" reset-type="initial" label-width="calc(4em + 12px)" label-align="top" class="eco-search-form">
        <t-form-item label="编号" name="newsId">
          <t-input v-model="queryParams.newsId" placeholder="请输入编号" clearable @enter="handleQuery" />
        </t-form-item>
        <t-form-item label="新闻标题" name="newsTitle">
          <t-input v-model="queryParams.newsTitle" placeholder="请输入新闻标题" clearable @enter="handleQuery" />
        </t-form-item>
        <t-form-item label="环保新闻" name="conferenceInfo" >
            <t-select v-model="queryParams.conferenceInfoId"
                      clearable placeholder="请选择环保新闻"
                      :scroll="{ type: 'virtual' }"
                      :popup-props="{ overlayInnerStyle: { height: '150px',width:'500px' } }"
                      auto-width
            >
                <template #prefixIcon>
                    <browse-icon style="margin-right: 8px" />
                </template>
                <template #panelTopContent>
                    <div :style="{ position: 'sticky', top: '0', zIndex: 1 }">
                        <t-textarea v-model="xhljConferenceInfoSearch" placeholder="请输入关键词搜索" @change="onSearchXhljConferenceInfo" />
                    </div>
                </template>
                <t-option v-for="item in  xhljConferenceInfoOptions" :key="item.value" :value="item.value" :label="item.label"></t-option>
            </t-select>
        </t-form-item>
        <t-form-item label="新闻内容" name="newsContent">
          <t-input v-model="queryParams.newsContent" placeholder="请输入新闻内容" clearable @enter="handleQuery" />
        </t-form-item>
        <t-form-item label-width="0px">
            <t-space align="end" style="height: 64px">
                <t-button theme="primary" class="eco-btn eco-btn-search" @click="handleQuery">
                    <template #icon> <search-icon /></template>
                    搜索
                </t-button>
                <t-button theme="default" class="eco-btn eco-btn-reset" @click="resetQuery">
                    <template #icon> <refresh-icon /></template>
                    重置
                </t-button>
            </t-space>
        </t-form-item>
      </t-form>

      <t-table
        v-model:column-controller-visible="columnControllerVisible"
        :loading="loading"
        hover
        row-key="newsId"
        :data="newsList"
        :columns="columns"
        :selected-row-keys="ids"
        select-on-row-click
        :pagination="pagination"
        :column-controller="{
          hideTriggerButton: true,
        }"
        :sort="sort"
        show-sort-column-bg-color
        class="eco-table"
        @sort-change="handleSortChange"
        @select-change="handleSelectionChange"
      >
        <template #topContent>
          <t-row class="eco-toolbar">
            <t-col flex="auto">
              <t-button v-hasPermi="['xhlj:news:add']" theme="primary" class="eco-btn eco-btn-add" @click="handleAdd">
                <template #icon> <add-icon /></template>
                新增新闻
              </t-button>
              <t-button
                v-hasPermi="['xhlj:news:edit']"
                theme="default"
                variant="outline"
                class="eco-btn eco-btn-edit"
                :disabled="single"
                @click="handleUpdate()"
              >
                <template #icon> <edit-icon /> </template>
                修改
              </t-button>
              <t-button
                v-hasPermi="['xhlj:news:remove']"
                theme="danger"
                variant="outline"
                class="eco-btn eco-btn-delete"
                :disabled="multiple"
                @click="handleDelete()"
              >
                <template #icon> <delete-icon /> </template>
                删除
              </t-button>
              <t-button v-hasPermi="['xhlj:news:export']" theme="default" variant="outline" class="eco-btn eco-btn-export" @click="handleExport">
                <template #icon> <download-icon /> </template>
                导出
              </t-button>
              <span class="eco-selected-count">已选 {{ ids.length }} 项</span>
            </t-col>
            <t-col flex="none">
              <t-button theme="default" shape="square" variant="outline" class="eco-btn eco-btn-search-toggle" @click="showSearch = !showSearch">
                <template #icon> <search-icon /> </template>
              </t-button>
              <t-button theme="default" variant="outline" class="eco-btn eco-btn-settings" @click="columnControllerVisible = true">
                <template #icon> <setting-icon /> </template>
                列配置
              </t-button>
            </t-col>
          </t-row>
        </template>



        <template #conferenceInfo="{ row }">
            <div v-if="row.conferenceInfo && Object.keys(row.conferenceInfo).length > 1" class="eco-conference-info">
              <span class="eco-conference-name">{{ row.conferenceInfo[Object.keys(row.conferenceInfo)[1]] }}</span>
              <span class="eco-conference-id">（编号为{{ row.conferenceInfo[Object.keys(row.conferenceInfo)[0]] }}）</span>
            </div>
        </template>

        <template #sysUser="{ row }">
            <span v-if="row.sysUser && Object.keys(row.sysUser).length > 1">
              {{ row.sysUser[Object.keys(row.sysUser)[1]] }}（编号为{{ row.sysUser[Object.keys(row.sysUser)[0]] }}）
            </span>
        </template>



        <template #newsImage="{ row }">
            <image-preview :src="row.newsImage" :width="60" :height="60" />
        </template>


        <template #newsVideoFile="{ row }">
            <t-tooltip
                v-if="row.newsVideoFile"
                v-for="(url, index) in row.newsVideoFile.split(',')"
                :key="index"
                :content="getUrlFileName(url)"
                destroy-on-close
                show-arrow
                placement="top-left"
                theme="light"
            >
                <t-link :href="url" @click.prevent="previewOrRedirect(url)" class="custom-link" theme="primary" target="_blank">
                    {{ getUrlFileName(url) }}
                </t-link>
            </t-tooltip>
        </template>




        <template #operation="{ row }">
          <t-space :size="8" break-line class="eco-operation">
            <t-link v-hasPermi="['xhlj:news:query']" theme="primary" hover="color" class="eco-link eco-link-detail" @click.stop="handleDetail(row)">
              <browse-icon />详情
            </t-link>
            <t-link v-hasPermi="['xhlj:news:edit']" theme="primary" hover="color" class="eco-link eco-link-edit" @click.stop="handleUpdate(row)">
              <edit-icon />修改
            </t-link>
            <t-link v-hasPermi="['xhlj:news:remove']" theme="danger" hover="color" class="eco-link eco-link-delete" @click.stop="handleDelete(row)">
              <delete-icon />删除
            </t-link>
          </t-space>
        </template>
      </t-table>
    </t-space>
    <!-- 添加或修改环保新闻新闻对话框 -->
    <t-dialog
      v-model:visible="open"
      :header="title"
      destroy-on-close
      :close-on-overlay-click="false"
      width="1100px"
      attach="body"
      class="eco-dialog"
      :confirm-btn="{
        loading: buttonLoading,
      }"
      @confirm="onConfirm"
    >
      <t-loading :loading="buttonLoading">
        <t-form
          ref="newsRef"
          label-align="top"
          :data="form"
          :rules="rules"
          label-width="calc(5em + 41px)"
          scroll-to-first-error="smooth"
          @submit="submitForm"
          layout="inline"
        >

          <t-form-item label="新闻标题" name="newsTitle" style="width: 90%">
            <t-textarea v-model="form.newsTitle"
                        placeholder="请输入新闻标题"
                        name="description"
                        :autosize="{ minRows: 3, maxRows: 6 }"
            />
          </t-form-item>

    <t-form-item label="环保新闻" name="conferenceInfo" style="width: 100%">
        <t-select v-model="form.conferenceInfoId"
                  clearable placeholder="请选择环保新闻"
                  :scroll="{ type: 'virtual' }"
                  :popup-props="{ overlayInnerStyle: { height: '150px',width:'500px' } }"
                  auto-width
             >
            <template #prefixIcon>
                <browse-icon style="margin-right: 8px" />
            </template>
            <template #panelTopContent>
                <div :style="{ position: 'sticky', top: '0', zIndex: 1 }">
                    <t-textarea v-model="xhljConferenceInfoSearch" placeholder="请输入关键词搜索" @change="onSearchXhljConferenceInfo" />
                </div>
            </template>
            <t-option v-for="item in xhljConferenceInfoOptions" :key="item.value" :value="item.value" :label="item.label"></t-option>
        </t-select>
    </t-form-item>

          <t-form-item label="新闻内容" name="newsContent" >
            <editor v-model="form.newsContent" />
          </t-form-item>

          <t-form-item label="新闻地点" name="newsLocation" style="width: 90%">
            <t-textarea v-model="form.newsLocation"
                        placeholder="请输入新闻地点"
                        name="description"
                        :autosize="{ minRows: 3, maxRows: 6 }"
            />
          </t-form-item>

          <t-form-item label="新闻图片" name="newsImage" style="width: 100%">
            <image-upload v-model="form.newsImage" :limit="0" />
          </t-form-item>

          <t-form-item label="新闻图片描述" name="newsDescription" style="width: 90%">
            <t-textarea v-model="form.newsDescription"
                        placeholder="请输入新闻图片描述"
                        name="description"
                        :autosize="{ minRows: 3, maxRows: 6 }"
            />
          </t-form-item>

          <t-form-item label="新闻视频" name="newsVideoFile" style="width: 100%">
            <file-upload v-model="form.newsVideoFile" :limit="0"/>
          </t-form-item>

          <t-form-item label="新闻视频描述" name="newsVideoDescription" style="width: 90%">
            <t-textarea v-model="form.newsVideoDescription"
                        placeholder="请输入新闻视频描述"
                        name="description"
                        :autosize="{ minRows: 3, maxRows: 6 }"
            />
          </t-form-item>

        </t-form>
      </t-loading>
    </t-dialog>

        <!-- 办公文件预览 -->
        <t-dialog
            :visible="localOfficeFileProviewVisible"
            title="文档预览"
            width="70%"
            style="position: absolute"
            :close-btn="false"
            close-on-esc-keydown
            :footer="false"
            show-overlay
            placement="center"
            @close="updateOfficeFileProviewVisible(false)"
        >
            <template #default>
                <t-link :href="file" theme="primary" hover="color"><t-button>下载文件</t-button></t-link>
                <!-- 动态选择预览组件 -->
                <component :is="fileTypeComponents[fileType]" v-if="fileType && fileTypeComponents[fileType]" :src="file" />
                <!-- 如果文件类型不被支持 -->
                <div v-else>该文件类型不支持预览。</div>
            </template>
        </t-dialog>
    <!-- 环保新闻新闻详情 -->
    <t-dialog
      v-model:visible="openView"
      header="🌱 环保新闻详情"
      placement="center"
      width="800px"
      attach="body"
      :footer="false"
      class="eco-dialog eco-detail-dialog"
    >
      <my-descriptions :loading="openViewLoading">

        <t-descriptions-item label="编号">{{ form.newsId }}</t-descriptions-item>

        <t-descriptions-item label="新闻标题" :span="2">{{ form.newsTitle }}</t-descriptions-item>

        <span v-if="form.conferenceInfo && Object.keys(form.conferenceInfo).length > 1">
              {{ form.conferenceInfo[Object.keys(form.conferenceInfo)[1]] }}（编号为{{ form.conferenceInfo[Object.keys(form.conferenceInfo)[0]] }}）
        </span>

        <span v-if="form.sysUser && Object.keys(form.sysUser).length > 1">
              {{ form.sysUser[Object.keys(form.sysUser)[1]] }}（编号为{{ form.sysUser[Object.keys(form.sysUser)[0]] }}）
        </span>

        <t-descriptions-item label="新闻内容" :span="2">
          <editor-preview :html-text="form.newsContent" />
        </t-descriptions-item>

        <t-descriptions-item label="新闻地点" :span="2">{{ form.newsLocation }}</t-descriptions-item>

        <t-descriptions-item label="新闻图片">
          <image-preview :src="form.newsImage" :width="60" :height="60" />
        </t-descriptions-item>

        <t-descriptions-item label="新闻图片描述" :span="2">{{ form.newsDescription }}</t-descriptions-item>

        <t-descriptions-item label="新闻视频">{{ form.newsVideoFile }}</t-descriptions-item>

        <t-descriptions-item label="新闻视频描述" :span="2">{{ form.newsVideoDescription }}</t-descriptions-item>
        <t-descriptions-item label="创建时间">{{ parseTime(form.createTime) }}</t-descriptions-item>

      </my-descriptions>
    </t-dialog>
  </t-card>
</template>

<script lang="tsx" setup>
defineOptions({
  name: 'News',
});
import {
  AddIcon,
  DeleteIcon,
  DownloadIcon,
  EditIcon,
  RefreshIcon,
  SearchIcon,
  SettingIcon,
  BrowseIcon,
  BookIcon
} from 'tdesign-icons-vue-next';
import type { SelectProps, TextareaProps, FormInstanceFunctions, FormRule, PageInfo, PrimaryTableCol, SubmitContext, TableSort } from 'tdesign-vue-next';
import { computed, getCurrentInstance, ref } from 'vue';
import { ArrayOps } from '@/utils/array';

import type { XhljNewsForm, XhljNewsQuery, XhljNewsVo } from '@/api/xhlj/model/newsModel';
import { listNews, getNews, delNews, addNews, updateNews } from '@/api/xhlj/news';
import type { XhljConferenceInfoQuery } from '@/api/xhlj/model/conferenceInfo';
import { listConferenceInfo } from '@/api/xhlj/conferenceInfo';
import Editor from '@/components/editor/index.vue';
import EditorPreview from '@/components/editor-preview/index.vue';

// office文件预览
import VueOfficePdf from '@vue-office/pdf';
import VueOfficeExcel from '@vue-office/excel';
import '@vue-office/excel/lib/index.css';
import VueOfficeDocx from '@vue-office/docx';
import '@vue-office/docx/lib/index.css';
// video预览
import Video from '@/components/video/index.vue'

const { proxy } = getCurrentInstance();

const openView = ref(false);
const openViewLoading = ref(false);
const newsRef = ref<FormInstanceFunctions>();
const open = ref(false);
const buttonLoading = ref(false);
const title = ref('');
const newsList = ref<XhljNewsVo[]>([]);
const loading = ref(false);
const columnControllerVisible = ref(false);
const showSearch = ref(true);
const total = ref(0);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const sort = ref<TableSort>();
const xhljConferenceInfoQueryParams = ref<XhljConferenceInfoQuery>({
    pageNum: 1,
    pageSize: 10000,
});
const xhljConferenceInfoList = ref<SelectProps['options']>([]);
const xhljConferenceInfoOptions = ref<SelectProps['options']>([]);
const xhljConferenceInfoSearch = ref('');
const onSearchXhljConferenceInfo = () => {
        xhljConferenceInfoOptions.value = xhljConferenceInfoList.value
            .map((item) => ({
                label: item[Object.keys(item)[1]],
                value: item[Object.keys(item)[0]],
            }))
            .filter(option => option.label.includes(xhljConferenceInfoSearch.value));
};
/** 查询环保新闻列表 */
async function getXhljConferenceInfoList() {
    listConferenceInfo(xhljConferenceInfoQueryParams.value)
        .then((response) => {
            xhljConferenceInfoList.value = response.rows;
            const labelValue = response.rows.map((item) => ({
                label: item[Object.keys(item)[1]],
                value: item[Object.keys(item)[0]],
            }));
            xhljConferenceInfoOptions.value = labelValue;
            console.log("xhljConferenceInfoList", xhljConferenceInfoList.value)
            console.log("xhljConferenceInfoOptions", xhljConferenceInfoOptions)
        })
}

    // office预览
    // 定义Props和Emits
    const props = defineProps<{
        officeFileProviewVisible: boolean;
        officeFile?: string;
    }>();
    const emit = defineEmits(['update:officeFileProviewVisible']);
    // 文件类型组件映射
    const fileTypeComponents = {
        docx: VueOfficeDocx,
        xlsx: VueOfficeExcel,
        pdf: VueOfficePdf,
        mp4: Video,
    } as const;
    // 控制预览弹窗显示的本地状态
    const localOfficeFileProviewVisible = ref(props.officeFileProviewVisible);
    const file = ref(props.officeFile || '');
    // 更新父组件的prop值
    const updateOfficeFileProviewVisible = (value: boolean) => {
        localOfficeFileProviewVisible.value = value;
        emit('update:officeFileProviewVisible', value);
    };
    // 根据URL预览或跳转
    const previewOrRedirect = (url: string) => {
        const extension = url.slice(((url.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase();
        if (fileTypeComponents[extension]) {
            file.value = url;
            updateOfficeFileProviewVisible(true);
        } else {
            window.open(url);
        }
    };
    // 从URL中获取文件名
    const getUrlFileName = (url: string): string => url.substring(url.lastIndexOf('/') + 1);
    // 计算文件类型
    const fileType = computed(() => {
        return file.value ? file.value.slice(file.value.lastIndexOf('.') + 1).toLowerCase() : null;
    });
// 校验规则
const rules = ref<Record<string, Array<FormRule>>>({
});
// 列显隐信息
const columns = ref<Array<PrimaryTableCol>>([
  { title: `选择列`, colKey: 'row-select', type: 'multiple', width: 50, align: 'center',fixed: 'left' },
  { title: `编号`, colKey: 'newsId', align: 'center', ellipsis: {theme: 'light'} ,fixed: 'left'},
  { title: `新闻标题`, colKey: 'newsTitle', align: 'center', minWidth: 140,  ellipsis: {theme: 'light'} },
  { title: `环保新闻`, colKey: 'conferenceInfo', align: 'center', minWidth: 155, ellipsis: {theme: 'light'},
        className: ({ row }) => {
            return 'custom-cell-class-name';
        },
        attrs: ({ row }) => {
            return {
                style: {
                    color: '#fff', // 白色文字
                    fontWeight: 'bold', // 字体加粗
                    background: 'linear-gradient(to right, #4facfe 0%, #00f2fe 100%)', // 渐变背景
                    transition: 'all 0.3s ease', // 添加过渡效果
                    borderRadius: '4px', // 圆角
                }
            };
        }
,
  },
  { title: `系统用户`, colKey: 'sysUser', align: 'center', minWidth: 155, ellipsis: {theme: 'light'},
  },
  { title: `新闻内容`, colKey: 'newsContent', align: 'center', minWidth: 140,  ellipsis: {theme: 'light'} },
  { title: `新闻地点`, colKey: 'newsLocation', align: 'center', minWidth: 140,  ellipsis: {theme: 'light'} },
  { title: `新闻图片`, colKey: 'newsImage', align: 'center', minWidth: 160 },
  { title: `新闻图片描述`, colKey: 'newsDescription', align: 'center', minWidth: 140,  ellipsis: {theme: 'light'} },
  { title: `新闻视频`, colKey: 'newsVideoFile', align: 'center', minWidth: 180 },
  { title: `新闻视频描述`, colKey: 'newsVideoDescription', align: 'center', minWidth: 140,  ellipsis: {theme: 'light'} },
  { title: `新闻标签`, colKey: 'newTags', align: 'center' },
  { title: `创建时间`, colKey: 'createTime', align: 'center', minWidth: 112, width: 120, sorter: true },
  { title: `操作`, colKey: 'operation', align: 'center', width: 120 , fixed: 'right'},
]);
// 提交表单对象
const form = ref<XhljNewsVo & XhljNewsForm>({});
// 查询对象
const queryParams = ref<XhljNewsQuery>({
  pageNum: 1,
  pageSize: 10,
  newsId: undefined,
  newsTitle: undefined,
  conferenceInfo: undefined,
  sysUser: undefined,
  newsContent: undefined,
  newTags: undefined,
});
// 分页
const pagination = computed(() => {
  return {
    current: queryParams.value.pageNum,
    pageSize: queryParams.value.pageSize,
    total: total.value,
    showJumper: true,
    onChange: (pageInfo: PageInfo) => {
      queryParams.value.pageNum = pageInfo.current;
      queryParams.value.pageSize = pageInfo.pageSize;
      getList();
    },
  };
});

/** 查询环保新闻新闻列表 */
function getList() {
  loading.value = true;
  listNews(queryParams.value)
    .then((response) => {
      newsList.value = response.rows;
      total.value = response.total;
      console.log("News", response.rows)
    })
    .finally(() => (loading.value = false));
}

// 表单重置
function reset() {
  form.value = {};
  proxy.resetForm('newsRef');
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  queryParams.value.pageNum = 1;
  handleSortChange(null);
}

/** 排序触发事件 */
function handleSortChange(value?: TableSort) {
  sort.value = value;
  if (Array.isArray(value)) {
    queryParams.value.orderByColumn = value.map((item) => item.sortBy).join(',');
    queryParams.value.isAsc = value.map((item) => (item.descending ? 'descending' : 'ascending')).join(',');
  } else {
    queryParams.value.orderByColumn = value?.sortBy;
    queryParams.value.isAsc = value?.descending ? 'descending' : 'ascending';
  }
  getList();
}

/** 多选框选中数据 */
function handleSelectionChange(selection: Array<string | number>) {
  ids.value = selection;
  single.value = selection.length !== 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = '添加环保新闻新闻';
}

/** 详情按钮操作 */
function handleDetail(row: XhljNewsVo) {
  reset();
  openView.value = true;
  openViewLoading.value = true;
  const newsId = row.newsId;
  getNews(newsId).then((response) => {
    form.value = response.data;
    openViewLoading.value = false;
  });
}

/** 修改按钮操作 */
function handleUpdate(row?: XhljNewsVo) {
  buttonLoading.value = true;
  reset();
  open.value = true;
  title.value = '修改环保新闻新闻';
  const newsId = row?.newsId || ids.value.at(0);
  getNews(newsId).then((response) => {
    buttonLoading.value = false;
    form.value = response.data;
  });
}

/** 提交按钮 */
function onConfirm() {
  newsRef.value.submit();
}

/** 提交表单 */
function submitForm({ validateResult, firstError }: SubmitContext) {
  if (validateResult === true) {
    buttonLoading.value = true;
    const msgLoading = proxy.$modal.msgLoading('提交中...');
    if (form.value.newsId) {
      updateNews(form.value)
        .then(() => {
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        })
        .finally(() => {
          buttonLoading.value = false;
          proxy.$modal.msgClose(msgLoading);
        });
    } else {
      addNews(form.value)
        .then(() => {
          proxy.$modal.msgSuccess('新增成功');
          open.value = false;
          getList();
        })
        .finally(() => {
          buttonLoading.value = false;
          proxy.$modal.msgClose(msgLoading);
        });
    }
  } else {
    proxy.$modal.msgError(firstError);
  }
}

/** 删除按钮操作 */
function handleDelete(row?: XhljNewsVo) {
  const newsIds = row?.newsId || ids.value;
  proxy.$modal.confirm(`是否确认删除环保新闻新闻编号为${newsIds}的数据项？`, () => {
    const msgLoading = proxy.$modal.msgLoading('正在删除中...');
    return delNews(newsIds)
      .then(() => {
        ids.value = ArrayOps.fastDeleteElement(ids.value, newsIds);
        getList();
        proxy.$modal.msgSuccess('删除成功');
      })
      .finally(() => {
        proxy.$modal.msgClose(msgLoading);
      });
  });
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    'xhlj/news/export',
    {
      ...queryParams.value,
    },
    `news_${new Date().getTime()}.xlsx`,
  );
}

onMounted(() => {
    getXhljConferenceInfoList();
    getList();
})


</script>
<style>
/* 环保主题样式 */
.eco-news-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #10b981;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.15);
    overflow: hidden;
}

.eco-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 24px;
    margin: -16px -16px 24px -16px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.eco-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="80" r="1" fill="rgba(255,255,255,0.1)"/></svg>');
    animation: float 20s linear infinite;
}

@keyframes float {
    0% { transform: translateX(-50px) translateY(-50px); }
    100% { transform: translateX(50px) translateY(50px); }
}

.eco-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    position: relative;
    z-index: 1;
}

.eco-icon {
    font-size: 32px;
    margin-right: 12px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.eco-subtitle {
    font-size: 16px;
    margin: 0;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.eco-search-form {
    background: rgba(16, 185, 129, 0.05);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    margin-bottom: 20px;
}

.eco-btn {
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.eco-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.eco-btn:hover::before {
    left: 100%;
}

.eco-btn-search {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.eco-btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.eco-btn-reset {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    border: none;
    color: white;
}

.eco-btn-add {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.eco-btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.eco-btn-edit {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    color: white;
}

.eco-btn-delete {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    color: white;
}

.eco-btn-export {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    color: white;
}

.eco-toolbar {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    margin-bottom: 16px;
}

.eco-selected-count {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.eco-table {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}

.eco-table .t-table__header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.eco-table .t-table__header th {
    color: white;
    font-weight: 600;
    text-align: center;
}

.eco-table .t-table__body tr:nth-child(even) {
    background: rgba(16, 185, 129, 0.02);
}

.eco-table .t-table__body tr:hover {
    background: rgba(16, 185, 129, 0.08);
    transform: scale(1.01);
    transition: all 0.3s ease;
}

.t-table td.custom-cell-class-name {
    font-size: 16px;
    padding: 10px;
    text-shadow: none;
    transition: transform 0.3s ease, text-shadow 0.3s ease;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 600;
    border-radius: 6px;
    margin: 2px;
}

.t-table td.custom-cell-class-name:hover {
    transform: scale(1.05);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.eco-conference-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.eco-conference-name {
    font-weight: 600;
    color: #10b981;
    font-size: 14px;
}

.eco-conference-id {
    font-size: 12px;
    color: #6b7280;
}

.eco-operation {
    justify-content: center;
}

.eco-link {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
}

.eco-link-detail {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.eco-link-edit {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.eco-link-delete {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.eco-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.eco-dialog .t-dialog__header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.eco-dialog .t-dialog__body {
    background: #f8fffe;
}

.eco-detail-dialog .t-dialog__header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.custom-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 8px 16px;
    margin-top: 5px;
    border-radius: 20px;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease-in-out;
    font-weight: 500;
}

.custom-link:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 8px rgba(16, 185, 129, 0.4);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .eco-title {
        font-size: 24px;
    }
    
    .eco-icon {
        font-size: 28px;
    }
    
    .eco-subtitle {
        font-size: 14px;
    }
    
    .eco-toolbar {
        flex-direction: column;
        gap: 12px;
    }
    
    .eco-btn {
        width: 100%;
        margin-bottom: 8px;
    }
}
</style>
